import { listSimpleDept } from '@/api/system/dept'
import type { BasicColumn, FormSchema } from '@/components/Table'
import { useRender } from '@/components/Table'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'

export const columns: BasicColumn[] = [
  {
    title: '病区名称',
    dataIndex: 'name',
    width: 180,
  },

  {
    title: '病区编码',
    dataIndex: 'code',
    width: 180,
  },
  {
    title: '首拼',
    dataIndex: 'pinYin',
    width: 180,
  },
  {
    title: '部门',
    dataIndex: 'deptId',
    width: 180,
    customRender: ({ record }) => {
      return useRender.renderTag(record.dept && record.dept.name)
    },
  },
  // {
  //   title: '科主任工号',
  //   dataIndex: 'hszGh',
  //   width: 180,
  // },
  // {
  //   title: '护士长工号',
  //   dataIndex: 'kzrGh',
  //   width: 180,
  // },
  // {
  //   title: '康复治疗师工号',
  //   dataIndex: 'kfzlszGh',
  //   width: 180,
  // },
  {
    title: '病区状态',
    dataIndex: 'status',
    width: 180,
    customRender: ({ text }) => {
      return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS)
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
    customRender: ({ text }) => {
      return useRender.renderDate(text)
    },
  },
  {
    title: '显示顺序',
    dataIndex: 'sort',
    width: 180,
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    label: '病区名称',
    field: 'name',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '显示顺序',
    field: 'sort',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '病区编码',
    field: 'code',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '首拼',
    field: 'pinYin',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '部门',
    field: 'deptId',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '科主任工号',
    field: 'hszGh',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '护士长工号',
    field: 'kzrGh',
    component: 'Select',
    colProps: { span: 8 },
  },
  {
    label: '康复治疗师工号',
    field: 'kfzlszGh',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '部门状态',
    field: 'status',
    component: 'Input',
    componentProps: {
      options: getDictOptions(DICT_TYPE.SYSTEM_DEPT_WARD_TYPE.toUpperCase()),
    },
    colProps: { span: 8 },
  },
  {
    label: '创建时间',
    field: 'createTime',
    component: 'RangePicker',
    colProps: { span: 8 },
  },
]

export const createFormSchema: FormSchema[] = [
  {
    label: '病区名称',
    field: 'name',
    required: true,
    component: 'Input',
  },
  {
    label: '病区编码',
    field: 'code',
    required: true,
    component: 'Input',
  },
  {
    label: '首拼',
    field: 'pinYin',
    component: 'Input',
    required: true,
  },
  {
    label: '归属部门',
    field: 'deptId',
    required: true,
    component: 'ApiTreeSelect',
    componentProps: {
      api: () => listSimpleDept(),
      handleTree: 'id',
    },
  },
  {
    label: '病区状态',
    field: 'status',
    required: true,
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.COMMON_STATUS),
    },

  },
  {
    label: '显示顺序',
    field: 'sort',
    required: true,
    component: 'Input',
  },
  // {
  //   label: '科主任工号',
  //   field: 'hszGh',
  //   component: 'Input',
  // },
  // {
  //   label: '护士长工号',
  //   field: 'kzrGh',
  //   component: 'Input',
  // },
  // {
  //   label: '康复治疗师工号',
  //   field: 'kfzlszGh',
  //   component: 'Input',
  // },

]

export const updateFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input',
  },
  {
    label: '病区名称',
    field: 'name',
    required: true,
    component: 'Input',
  },
  {
    label: '病区编码',
    field: 'code',
    component: 'Input',
  },
  {
    label: '首拼',
    field: 'pinYin',
    component: 'Input',
  },

  {
    label: '归属部门',
    field: 'deptId',
    required: true,
    component: 'ApiTreeSelect',
    componentProps: {
      api: () => listSimpleDept(),
      handleTree: 'id',
    },
  },
  // {
  //   label: '科主任工号',
  //   field: 'hszGh',
  //   component: 'Input',
  // },
  // {
  //   label: '护士长工号',
  //   field: 'kzrGh',
  //   component: 'Input',
  // },
  // {
  //   label: '康复治疗师工号',
  //   field: 'kfzlszGh',
  //   component: 'Input',
  // },
  {
    label: '病区状态',
    field: 'status',
    required: true,
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.COMMON_STATUS),
    },

  },
  {
    label: '显示顺序',
    field: 'sort',
    required: true,
    component: 'Input',
  },
]
